package com.vtuzx.kingdee.xqc_core.dao;

import com.mongodb.client.result.InsertManyResult;
import com.vtuzx.core.db.mongo.impl.VtuzxDaoImpl;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * 即时库存分录履历Dao
 */
@Component
public class InventoryHistoryDetailDao extends VtuzxDaoImpl {
    /** 集合名 */
    public static final String NAME = "t_inventory_history_detail";
    /**
     * 构造
     */
    public InventoryHistoryDetailDao() {
        super(NAME);
    }

    /**
     * 插入履历
     *
     * @param _userId 用户ID
     * @param userName 用户名
     * @param documents 对象列表
     * @return insertId列表
     */
    public List<ObjectId> insertDetail(ObjectId _userId, String userName, List<Document> documents) {
        Date now = new Date();
        for(Document doc: documents) {
            doc.put("updateTime", now);
            doc.put("createTime", now);
        }
        InsertManyResult res = this.getCollection(null).insertMany(documents);
        System.out.println(res.getInsertedIds());
        return null;
    }
}